﻿using System.ComponentModel;

namespace Sidvall.Globalization
{
    public class CultureItem : INotifyPropertyChanged
    {
        #region Public Members

        public event PropertyChangedEventHandler PropertyChanged;

        #region Name

        private string _Name;
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                value = Sidvall.Business.ValidationManager.GetValidString(value, false, null);
                if (_Name == value)
                    return;
                _Name = value;
                OnPropertyChanged(nameof(Name));
            }
        }

        #endregion
        #region DisplayName

        private string _DisplayName;
        public string DisplayName
        {
            get
            {
                return _DisplayName;
            }
            set
            {
                if (_DisplayName == value)
                    return;
                _DisplayName = value;
                OnPropertyChanged(nameof(DisplayName));
            }
        }

        #endregion
        #region EnglishName

        private string _EnglishName;
        public string EnglishName
        {
            get
            {
                return _EnglishName;
            }
            set
            {
                if (_EnglishName == value)
                    return;
                _EnglishName = value;
                OnPropertyChanged(nameof(EnglishName));
            }
        }

        #endregion

        #region Copy

        public CultureItem Copy()
        {
            return new CultureItem()
            {
                _DisplayName = this.DisplayName,
                _EnglishName = this.EnglishName,
                _Name = this.Name,
            };
        }

        #endregion
        #region OnPropertyChanged

        protected void OnPropertyChanged(string propertyName)
        {
            OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged.Invoke(this, args);
        }

        #endregion
        #region ToString

        public override string ToString()
        {
            return this.DisplayName;
        }

        #endregion

        #endregion
    }
}
